<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>跳转页面</title>
    <style>
        p {
            text-align: center;
        }

        span {
            color: red;
        }
    </style>
</head>
<body>
<p>
    注册成功<span id="time">3</span>秒后自动跳转到百度
</p>
</body>
<script>
    //定义一个变量
    let num = 3;
    function s() {
        //每一次计时num-1
        num--;
        //判断
        if (num<=0){
            //跳转
            location.href="https://www.baidu.com/";
        }
        //根据id获取内容
        let span =document.getElementById("time");
        span.innerHTML = num;
    }
    //设置循环定时器,一秒执行一次方法
    setInterval("s()",1000);
</script>
</html>